const md = require('../../utils/md5.js');
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    inputData: {
      input_value: "",//输入框的初始内容
      value_length: 0,//输入框密码位数
      isNext: true,//是否有下一步的按钮
      get_focus: true,//输入框的聚焦状态
      focus_class: true,//输入框聚焦样式
      value_num: [1, 2, 3, 4, 5, 6],//输入框格子数
      height: "80rpx",//输入框高度
      width: "560rpx",//输入框宽度
      see: false,//是否明文展示
      interval: false,//是否显示间隔格子
      maxlength:'6'
    },
    val_arr: [],
    input_value: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({
      userinfo: wx.getStorageSync('userinfo')
    })
  },


  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  valueSix(e) {
    console.log(e.detail);
    var that = this;
    that.setData({
      paypassword: e.detail
    })
  },
  valueFour(e) {
    var that = this;
    that.setData({
      msg: e.detail
    })
    console.log(444444444);
  },
  formSubmit: function (e) {
    console.log('form发生了submit事件，携带数据为：', e.detail.value);
    var that = this;
    var pwd = that.data.paypassword;
    // return;
    if (pwd.length != 6) {
      wx.showModal({
        title: '',
        content: '支付密码必须为6位数字',
      })
      return;
    }
    wx.showLoading({
      title: '请稍候...',
    })
    var apinameIsMeb = "/Action/PK01/SMSVerifySend";
    var timestamp = new Date().getTime();
    timestamp = parseInt(timestamp / 1000);
    var md5IsMeb = md.hexMD5(app.server.appid + timestamp + apinameIsMeb + app.server.appkey);
    wx.request({
      //后台接口地址
      url: app.server.url + apinameIsMeb,
      data: {
        sign: md5IsMeb,
        appid: app.server.appid,
        tmsp: timestamp,
        mobile: that.data.userinfo.Tel
      },
      method: 'POST',
      header: { 'content-type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        console.log(res);
        // if (res.data.data == true) {
          
        // }
      },
      complete:function(){
        wx.hideLoading();
        wx.navigateTo({
          url: '/pages/changepwd2/changepwd2?pwd=' + pwd,
        })
      }
    })

  },
})